/*
* 回溯算法求排列
* */
const rl = require('readline').createInterface({ input: process.stdin })

let arr = []

rl.on('line', (line) => {
	console.log(line)
	if (line) {
		arr = line.split(' ')
		console.log(start())
	}
})

function start () {
	const rst = []
	
	const temp = []
	
	function backtracking (arr2) {
		if (temp.length === arr.length) {
			rst.push([...temp])
			return
		}
		
		for (let i = 0; i < arr2.length; i ++) {
			temp.push(arr2[i])
			const newArr = [...arr2]
			newArr.splice(i, 1)
			backtracking(newArr)
			temp.pop()
		}
	}
	
	backtracking([...arr])
	
	return rst
}
